home *** CD-ROM | disk | FTP | other *** search
/ Power Programmierung / Power-Programmierung (Tewi)(1994).iso / magazine / ins_msb / 9203 / recurtw.bas < prev    next >
BASIC Source File  |  1992-02-06  |  1KB  |  29 lines

  1. ' RecurTW.Bas - Recursive directory treewalk demonstration.
  2. ' $INCLUDE: 'TREEWALK.BI'
  3. ' $INCLUDE: 'DIRFUN.BI'
  4. ' In your programs in which you want to use the TreeWalk module,
  5. ' you'll similarly need to create your own ProcessDirectoryEntry.
  6. DECLARE SUB ProcessDirectoryEntry (PathSpec$, EntrySpec$, _
  7.            EntryRecord AS DirectoryRecord, Level%)
  8.  
  9. INPUT "Enter a path spec: ", Spec$
  10. Action% = 0
  11. DO WHILE Action% = 0
  12.   PRINT "Enter T for top-down traversal, or"
  13.   INPUT "enter B for bottoms-up traversal:", Action$
  14.   Action% = INSTR("TB", UCASE$(Action$))
  15. LOOP
  16. TreeWalk Spec$, Action%   ' Walk the directory tree.
  17. END
  18.  
  19. SUB ProcessDirectoryEntry (PathSpec$, EntrySpec$, _
  20.                          DirEnt AS DirectoryRecord, Level%)
  21. ' ProcessDirectoryEntry - Perform whatever action you want
  22. '                         with the contents of "DirEnt".
  23. ' Convert ASCIIZ string to normal string
  24. TrimmedEntry$ = MID$(DirEnt.FileName, 1, INSTR(DirEnt.FileName, CHR$(0)) - 1)
  25. IF Right$(TrimmedEntry$, 4) = RIGHT$(EntrySpec$, 4) THEN
  26.   PRINT "Level "; Level%; " "; PathSpec$; TrimmedEntry$
  27. END IF
  28. END SUB
  29.